<?php
namespace app\admin\model;

use think\Model;
class Log extends Model
{
    static public function success(){
        self::log(true);
    }

	static public function error(){
        self::log(false);
    }

    static private function log($type=true){
        if(null !== session('username'))
            $data['name']=session('username');
        else
            $data['name']='未知';
        $data['file']=get_url();
        $data['ip']=get_client_ip();
        $data['time']=time();
        $data['status']=$type? "成功": "失败";
        $log = M('log')->add($data);
    }
}
